package com.industrial.app.controller.formal;

import com.industrial.app.domain.formal.BizGycpcxlFormal;
import com.industrial.app.service.IBizGycpcxlFormalService;
import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 工业产品销售率正式Controller
 *
 * @author ruoyi
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/biz/gycpcxl/formal")
public class BizGycpcxlFormalController extends BaseController
{
    @Autowired
    private IBizGycpcxlFormalService bizGycpcxlFormalService;

    /**
     * 查询工业产品销售率正式列表
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizGycpcxlFormal bizGycpcxlFormal)
    {
        startPage();
        List<BizGycpcxlFormal> list = bizGycpcxlFormalService.selectBizGycpcxlFormalList(bizGycpcxlFormal);
        return getDataTable(list);
    }

    /**
     * 导出工业产品销售率正式列表
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:export')")
//    @Log(title = "工业产品销售率正式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizGycpcxlFormal bizGycpcxlFormal)
    {
        List<BizGycpcxlFormal> list = bizGycpcxlFormalService.selectBizGycpcxlFormalList(bizGycpcxlFormal);
        ExcelUtil<BizGycpcxlFormal> util = new ExcelUtil<BizGycpcxlFormal>(BizGycpcxlFormal.class);
        util.exportExcel(response, list, "工业产品销售率正式数据");
    }

    /**
     * 获取工业产品销售率正式详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:query')")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(bizGycpcxlFormalService.selectBizGycpcxlFormalByBaseId(baseId));
    }

    /**
     * 新增工业产品销售率正式
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:add')")
//    @Log(title = "工业产品销售率正式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizGycpcxlFormal bizGycpcxlFormal)
    {
        return toAjax(bizGycpcxlFormalService.insertBizGycpcxlFormal(bizGycpcxlFormal));
    }

    /**
     * 修改工业产品销售率正式
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:edit')")
//    @Log(title = "工业产品销售率正式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizGycpcxlFormal bizGycpcxlFormal)
    {
        return toAjax(bizGycpcxlFormalService.updateBizGycpcxlFormal(bizGycpcxlFormal));
    }

    /**
     * 删除工业产品销售率正式
     */
//    @PreAuthorize("@ss.hasPermi('system:formal:remove')")
//    @Log(title = "工业产品销售率正式", businessType = BusinessType.DELETE)
    @DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(bizGycpcxlFormalService.deleteBizGycpcxlFormalByBaseIds(baseIds));
    }

    /**
     * <p>
     *     查询APP左上角的日期数据
     * </p>
     * @return 日期的集合
     */
    @GetMapping("/getUniqueDatesFromDatabase")
    public AjaxResult getUniqueDatesFromDatabase(){
        List<String> dateArgs = bizGycpcxlFormalService.getUniqueDatesFromDatabase();
        return AjaxResult.success(dateArgs);
    }
}
